package com.qlc.spring.cloud.demo.user.http;

import com.qlc.spring.cloud.demo.Result;
import com.qlc.spring.cloud.demo.user.VO.UserVO;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * Name:  UserHttpServiceFallBack
 * User:  wang chang
 * CreateTime: 2019-05-30 10:49
 **/
@Component
public class UserHttpServiceFallBack implements FallbackFactory<UserHttpService> {
    @Override
    public UserHttpService create(Throwable throwable) {
        return new UserHttpService() {

            @Override
            public Result<UserVO> getUserByCode(String userCode) {
                Result<UserVO> result = new Result<UserVO>();
                result.setCode("-2");
                result.setMessage("没有获取到对应的信息。");
                return result;
            }

            @Override
            public Result<Void> addUser(UserVO userVO) {
                return null;
            }
        };
    }
}
